﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IMC.Prepare.Core.Domain.Localization;
using IMC.Prepare.Core.Data;

namespace IMC.Prepare.Services.Localization
{
    public partial class LanguageService : ILanguageService
    {
        //private const string LANGUAGES_ALL_KEY = "IMC.Prepare.language.all-{0}";
        private readonly IRepository<Language> _languageRepository;
        //private readonly ICacheManager _cacheManager;

        public LanguageService(//ICacheManager cacheManager,
            IRepository<Language> languageRepository)
        {
            //_cacheManager = cacheManager;
            _languageRepository = languageRepository;
        }


        /// <summary>
        /// Gets all languages
        /// </summary>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Language collection</returns>
        public virtual IList<Language> GetAllLanguages(bool showHidden = false)
        {
            //string key = string.Format(LANGUAGES_ALL_KEY, showHidden);
            //return _cacheManager.Get(key, () =>
            //{
                var query = from l in _languageRepository.Table
                            orderby l.DisplayOrder
                            where showHidden || l.Published
                            select l;
                var languages = query.ToList();
                return languages;
            //});
        }
    }
}
